<?php

App::uses('AppModel', 'Model');

class Price extends AppModel {
    
    public $belongsTo = array('PriceGroup');
    public $order     = array('Price.label');
    
    public $validate = array(
        'label' => array(
            'rule'    => 'notEmpty',
            'message' => 'Morate uneti naziv'
        )
    );
    
    public function getUnits() {
        $type = preg_replace('/^enum\(|\)$|\'/i', '', $this->_schema['unit']['type']);
        $units = array();
        foreach (explode(',', $type) as $unit) {
            $units[$unit] = $unit;
        }
        return $units;
    }
    
}